package test.lx.com.view_qualify;

/**
 * Created by Administrator on 2015/10/6.
 */
public class CheckUtils {
    /**
     * 产生随机数
     */
    public static int [] getCheckNum(){
        int [] tempCheckNum = new int[Config.TEXT_LENGTH];
        for(int i = 0; i < Config.TEXT_LENGTH; i++){
            tempCheckNum[i] = (int) (Math.random() * 10);
        }
        return tempCheckNum;
    }


    /**
     * 产生线的坐标
     */

    public static int[] getLine(int height, int width){
        int [] tempCheckNum = {0,0,0,0};
        for(int i = 0; i < 4; i+=2){
            tempCheckNum[i] = (int) (Math.random() * width);
            tempCheckNum[i + 1] = (int) (Math.random() * height);
        }
        return tempCheckNum;
    }


    /**
     * 验证随机数
     */
    public static boolean checkNum(String userCheck, int[] checkNum) {
        if (userCheck.length() != 4) {
            return false;
        }
        String checkString = "";
        for (int i = 0; i < 4; i++) {
            checkString += checkNum[i];
        }
        if (userCheck.equals(checkString)) {
            return true;
        } else {
            return false;
        }
    }

    /**
     *  计算验证码的绘制y点位置
     * @param height 传入CheckView的高度值
     * @return
     */
    public static int getPositon(int height){
        int tempPositoin = (int) (Math.random() * height);
        if(tempPositoin < 20){
            tempPositoin += 20;
        }
        return tempPositoin;
    }






}
